package model.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;


/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:spring security
 *                             shiro
 * @date 2019/7/1 0001
 *
 * 由于引入<groupId>org.springframework.boot</groupId>
 *<artifactId>spring-boot-starter-security</artifactId>
 *这个，所有路径都会被拦截 ，这个配置类可以解决这个问题（释放）
 */
@Configuration
@EnableWebSecurity
public class SecurityBootConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                  .antMatchers("/**").permitAll()
//                .antMatchers("/reg").permitAll() //所有的路径都被允许   应该一些不需要登陆的路径被允许
//                .antMatchers("/password").permitAll()
//                .antMatchers("/user").permitAll()
//                .antMatchers("/c").permitAll()
                .anyRequest().authenticated()  //所有的请求都需要进行验证
                .and().csrf().disable();
    }
}
